package com.sharemarking.application.common.service;

import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.Root;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.stereotype.Service;

import com.sharemarking.application.common.entity.Employee;
import com.sharemarking.application.common.repository.EmployeeRepo;

@Service
public class EmployeeService {
	
	@Autowired
	private EmployeeRepo er;
	
	public Iterable<Employee> getAllEmployees(){
		return er.findAll(new Specification<Employee>() {
			
			@Override
			public Predicate toPredicate(Root<Employee> root, CriteriaQuery<?> cq, CriteriaBuilder cb) {
				return cb.notEqual(root.get("name").as(String.class), "ADMINISTRATOR");
			}
		});
	}
	

}
